/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Home
 */
@Entity
@Table(name = "computadoras", catalog = "sna2", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Computadoras.findAll", query = "SELECT c FROM Computadoras c"),
    @NamedQuery(name = "Computadoras.findByPiso", query = "SELECT c FROM Computadoras c WHERE c.piso = :piso"),
    @NamedQuery(name = "Computadoras.findByCodigo", query = "SELECT c FROM Computadoras c WHERE c.codigo = :codigo"),
    @NamedQuery(name = "Computadoras.findByEstado", query = "SELECT c FROM Computadoras c WHERE c.estado = :estado"),
    @NamedQuery(name = "Computadoras.findByNumeroDePerifericos", query = "SELECT c FROM Computadoras c WHERE c.numeroDePerifericos = :numeroDePerifericos")})
public class Computadoras implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 5)
    @Column(name = "piso")
    private String piso;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "codigo")
    private String codigo;
    @Size(max = 10)
    @Column(name = "estado")
    private String estado;
    @Size(max = 5)
    @Column(name = "numero_de_perifericos")
    private String numeroDePerifericos;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "computadoras")
    private Collection<Periferico> perifericoCollection;
    @JoinColumn(name = "codigo_laboratorio", referencedColumnName = "codigo")
    @ManyToOne(optional = false)
    private Laboratorio laboratorio;

    public Computadoras() {
    }

    public Computadoras(String codigo) {
        this.codigo = codigo;
    }

    public String getPiso() {
        return piso;
    }

    public void setPiso(String piso) {
        this.piso = piso;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    public String getNumeroDePerifericos() {
        return numeroDePerifericos;
    }

    public void setNumeroDePerifericos(String numeroDePerifericos) {
        this.numeroDePerifericos = numeroDePerifericos;
    }

    @XmlTransient
    public Collection<Periferico> getPerifericoCollection() {
        return perifericoCollection;
    }

    public void setPerifericoCollection(Collection<Periferico> perifericoCollection) {
        this.perifericoCollection = perifericoCollection;
    }

    public Laboratorio getLaboratorio() {
        return laboratorio;
    }

    public void setLaboratorio(Laboratorio laboratorio) {
        this.laboratorio = laboratorio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Computadoras)) {
            return false;
        }
        Computadoras other = (Computadoras) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Computadoras[ codigo=" + codigo + " ]";
    }
    
}
